package com.huifenqi.gateway.config;

import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.gateway.discovery.DiscoveryClientRouteDefinitionLocator;
import org.springframework.cloud.gateway.discovery.DiscoveryLocatorProperties;
import org.springframework.cloud.gateway.filter.factory.StripPrefixGatewayFilterFactory;
import org.springframework.cloud.gateway.handler.predicate.HostRoutePredicateFactory;
import org.springframework.cloud.gateway.route.RouteDefinitionLocator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lisheng
 * @description
 * @date 2018/11/9 11:25
 * @version:
 */
@Configuration
public class GatewayConfig {

    @Bean
    public RouteDefinitionLocator discoveryClientRouteDefinitionLocator(DiscoveryClient discoveryClient, DiscoveryLocatorProperties properties) {
        return new DiscoveryClientRouteDefinitionLocator(discoveryClient, properties);
    }

    @Bean
    public StripPrefixGatewayFilterFactory stripPrefixGatewayFilterFactory(){
        return new StripPrefixGatewayFilterFactory();
    }

    @Bean
    public HostRoutePredicateFactory hostRoutePredicateFactory(){
        return new HostRoutePredicateFactory();
    }
}
